@SpringBootTest
class ConsumerServiceImplTest {

    @Autowired
    private ConsumerMapper consumerMapper;

    @Test
    void ConsumerMapperTest1() {

        String username = "Jason";
        String password = "123";

        //测试是否存在用户
        boolean b = this.verityPasswd(username, password);
        if (b) {
            Consumer consumer = new Consumer();
            consumer.setUsername(username);
            List<Consumer> consumers = consumerMapper.selectList(new QueryWrapper<>(consumer));
            consumers.forEach(c -> System.out.println(c.toString()));
        } else {
            System.out.println("用户名或密码错误");
        }
    }

    boolean verityPasswd(String username, String password) {
        QueryWrapper<Consumer> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",username);
        String secretPassword = DigestUtils.md5DigestAsHex((Constants.SALT + password).getBytes(StandardCharsets.UTF_8));

        queryWrapper.eq("password",secretPassword);
        return consumerMapper.selectCount(queryWrapper) > 0;
    }
}
